Skip to content

feat(risk): composite risk scoring model with explainable factors (#252)#271

Open
Shikhar-404exe wants to merge 1 commit into
utksh1:mainfrom
Shikhar-404exe:252
Open

feat(risk): composite risk scoring model with explainable factors (#252)#271
Shikhar-404exe wants to merge 1 commit into
utksh1:mainfrom
Shikhar-404exe:252

Conversation

@Shikhar-404exe
Copy link
Copy Markdown

Implements a deterministic, explainable risk scoring model that prioritizes findings using five weighted factors.

#252

Scoring Formula

risk_score = severity×0.30 + exploitability×0.25 + asset_exposure×0.20 + recency×0.15 + confidence×0.10

Each factor includes a human-readable explanation of its contribution (label, raw value, score out of 10, weight, contribution, detail string).

Backend Changes

  • backend/secuscan/risk_scoring.py — scoring algorithm with compute_risk_score() and generate_risk_factors()
  • backend/secuscan/models.pyFinding model extended with exploitability, confidence, asset_exposure, risk_score, risk_factors
  • backend/secuscan/database.py — schema migration for 4 new columns
  • backend/secuscan/executor.py_compute_and_set_risk_score() called on finding upsert in both sync and async paths
  • backend/secuscan/routes.pyrisk_score, risk_factors, avg_risk_score exposed on GET /findings, GET /finding/{id}, GET /dashboard/summary

Frontend Changes

  • Findings.tsx — sidebar shows color-coded Risk Score card (red ≥7, amber 4–6.9, blue <4) with per-factor breakdown
  • TaskDetails.tsx — FindingDrawer shows Risk Score and factor breakdown

Testing

  • 17 backend unit tests in testing/backend/unit/test_risk_scoring.py covering:
    • Determinism, score bounds, default values
    • All severity levels mapping to correct scores
    • Factor generation correctness
    • Edge cases (null fields, extreme values, backward compat)
  • 7 frontend tests in frontend/testing/unit/pages/Findings.test.tsx covering:
    • Risk score visibility and color coding
    • Factor label rendering
    • Absence when score is null

…ksh1#252)

- Composite weighted score: severity (30%), exploitability (25%),
  asset exposure (20%), recency (15%), confidence (10%)
- Finding model extended with exploitability, confidence, asset_exposure,
  risk_score, risk_factors fields + DB migration
- API exposes risk_score, risk_factors, avg_risk_score on findings
  and dashboard endpoints
- Frontend shows color-coded Risk Score card and per-factor breakdown
  in Findings sidebar and TaskDetails drawer
- 17 backend unit tests for scoring determinism, bounds, defaults, edges
- 7 frontend tests for risk score visibility and coloring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant